package cn.gwm.flink.streaming.constant;

import cn.gwm.flink.streaming.strategy.vehiclepredict.DwsStrConstant;
import cn.gwm.flink.streaming.task.ChargePredictDwsTask;
import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : GW00280745
 * @date : 2023/1/15 9:26
 * @description :
 */
public class ChargePredictFields {
    private volatile static ChargePredictFields instance;
    private ChargePredictFields(){}
    public static ChargePredictFields ins() {
        if (instance == null) {
            synchronized (ChargePredictFields.class) {
                if (instance == null) {
                    instance = new ChargePredictFields();
                    instance.loadSrc();
                    instance.loadRes();
                    instance.loadConf();
                    instance.loadMultiRes();
                }
            }
        }
        return instance;
    }

    //字段区域 ---- dws数据源字段列表  start

    public String handleTime="handle_time";
    public String char3="#";
    public String srcFieldVin ="vin";
    public String srcFieldTid ="tid";
    public String srcFieldBrand ="brand";
    public String srcFieldVehicleType ="vehicletype";
    public String srcFieldBatterType ="batter_type";
    public String srcFieldBatterCapacity ="batter_capacity";
    public String srcFieldSource ="source";
    public String srcFieldBmsChargeSts ="bms_chrg_sts";
    public String srcFieldBmsBatterCurrRm ="bms_batt_curr_rm";
    public String srcFieldBmsRmcModuleTempMax ="bms_rmc_module_temp_max";
    public String srcFieldBmsRmcModuleTempMin ="bms_rmc_module_temp_min";
    public String srcFieldBmsDcConnect ="bms_dc_chrg_connect";
    public String srcFieldBmsObcConnect ="obc_connect_sts_ev";
    public String srcFieldBmsSoc ="bms_soc";
    public String srcFieldBmsSoh ="soh_cor";
    public String srcFieldBmsHeatReq ="bms_heatreq";
    public String srcFieldBmsCoolReq ="bms_coolreq";
    public String srcFieldSocLim ="tbox_batt_soc_lim";
    public String srcFieldModelCode ="model_code";
    public String srcFieldVoltMax ="bms_cell_volt_max";
    public String srcFieldVoltMin ="bms_cell_volt_min";
    public String srcFieldChrgTime ="bms_charge_time";
    public String srcFieldStartChargeTime ="startChargeTime";
    public String srcFieldLatitude ="latitude";
    public String srcFieldLongitude ="longitude";
    public String srcFieldMapId ="mapId";
    public String srcFieldAoiId ="aoiid";
    public String srcFieldPoiId ="poiid";
    public String srcFieldAcAmbTemp ="acambtemp";
    public String srcFieldAcOpen ="acopensts";
    public String srcFieldInnerSocMax ="bms_innersocmax";
    public String srcFieldInnerSocMin ="bms_innersocmin";
    public String srcFieldInletTemps ="bms_inlettemps";
    //字段区域 ---- dws数据源字段列表 - end

    public JSONObject srcInfo = new JSONObject();
    private void loadSrc(){
        srcInfo.put(srcFieldVin,"deviceId");
        srcInfo.put(srcFieldTid,"item_time");
        srcInfo.put(srcFieldBrand,"brand#ORA");
        srcInfo.put(srcFieldVehicleType,"vehicletype#ES13");
        srcInfo.put(srcFieldBatterType,"cell_battery_type");
        srcInfo.put(srcFieldBatterCapacity,"pack_capacity");
        srcInfo.put(srcFieldSource,"source#9");
        srcInfo.put(srcFieldBmsChargeSts,"BMS_ChrgSts");
        srcInfo.put(srcFieldBmsBatterCurrRm,"BMS_BattCurr_RM");
        srcInfo.put(srcFieldBmsRmcModuleTempMax,"BMS_RMC_ModuleTempMax");
        srcInfo.put(srcFieldBmsRmcModuleTempMin,"BMS_RMC_ModuleTempMin");
        srcInfo.put(srcFieldBmsDcConnect,"BMS_DCChrgConnect");
        srcInfo.put(srcFieldBmsObcConnect,"OBC_ConnectSts_EV");
        srcInfo.put(srcFieldBmsSoc,"BMS_InnerSOC");
        srcInfo.put(srcFieldBmsSoh,"BMS_SOH,SOH_COR");
        srcInfo.put(srcFieldBmsHeatReq,"BMS_HeatReq");
        srcInfo.put(srcFieldBmsCoolReq,"BMS_CoolReq");
        srcInfo.put(srcFieldSocLim,"Tbox_BattSOCLim");
        srcInfo.put(srcFieldModelCode,"model_code");
        srcInfo.put(srcFieldVoltMax,"BMS_CellVoltMax");
        srcInfo.put(srcFieldVoltMin,"BMS_CellVoltMin");
        srcInfo.put(srcFieldChrgTime,"BMS_ChrgTime");
        srcInfo.put(srcFieldStartChargeTime,"startChargeTime");
        srcInfo.put(srcFieldLatitude,"latitude");
        srcInfo.put(srcFieldLongitude,"longitude");
        srcInfo.put(srcFieldMapId,"mapId");
        srcInfo.put(srcFieldAoiId,"aoiId");
        srcInfo.put(srcFieldPoiId,"poiId");
        srcInfo.put(srcFieldAcAmbTemp,"ACAmbTemp");
        srcInfo.put(srcFieldAcOpen,"ACOpenSts");
        srcInfo.put(srcFieldInnerSocMax,"BMS_InnerSOCmax");
        srcInfo.put(srcFieldInnerSocMin,"BMS_InnerSOCmin");
        srcInfo.put(srcFieldInletTemps,"BMS_InletTemps");
    }

    //字段区域 ---- dws标准化字段列表 - start

    public String stdFieldDeviceId ="deviceId";
    public String stdFieldItemTime ="item_time";
    public String stdFieldBrand ="brand";
    public String stdFieldVehicleType ="vehicletype";
    public String stdFieldBatterType ="batter_type";
    public String stdFieldBatterCapacity ="batter_capcity";
    public String stdFieldSource ="source";
    public String stdFieldTemp ="temp";
    public String stdFieldDcObcSts ="dc_obc_sts";
    public String stdFieldHeatSts ="heat_sts";
    public String stdFieldTempAccTempRange ="tempAcc_temp_range";
    public String stdFieldTempAccBatterRange ="tempAcc_batter_range";
    public String stdFieldBatterMapTempRange ="batterMap_temp_range";
    public String stdFieldBatterMapSocRange ="batterMap_soc_range";
    public String stdFieldMoveAvgPoint ="move_avg_point";
    public String stdFieldMoveAvgProcess ="move_avg_process";
    public String stdFieldTempAccErr ="temp_acc_err";
    public String stdFieldBatterMapValue ="batter_map_value";
    public String stdFieldBatterValueErr ="batter_value_err";
    public String stdFieldTempIntervalPoint ="temp_interval_point";
    public String stdFieldBatterIntervalPoint ="batter_interval_point";
    public String stdFieldChargeInitPoint ="charge_init_point";
    public String stdFieldChargeInitPointFlag ="charge_init_point_flag";
    public String stdFieldSocIntervalPoint ="soc_interval_point";
    public String stdFieldEstimateTime ="esti_time";
    public String stdFieldEstimateTemp ="esti_temp";
    public String stdFieldPredictTime ="predict_time";
    public String stdFieldPredictTimeV1 = "predict_time_v1";
    public String stdFieldPredictTimeV2 = "predict_time_multidimension";
    public String defaultVal ="-999999";
    public String defaultBlankVal ="null";
    public String firstTimeField ="firstTime";

    //字段区域 ---- dws标准化字段列表 - end

    public JSONObject resInfo =new JSONObject();
    private void loadRes(){
        resInfo.put(stdFieldDeviceId,"vin");
        resInfo.put(stdFieldItemTime,"tid");
        resInfo.put(stdFieldBrand,"brand");
        resInfo.put(stdFieldVehicleType,"vehicletype");
        resInfo.put(stdFieldBatterType,"batter_type");
        resInfo.put(stdFieldBatterCapacity,"batter_capacity");
        resInfo.put(stdFieldSource,"source");
        resInfo.put("BMS_ChrgSts","bms_chrg_sts");
        resInfo.put("BMS_BattCurr_RM","bms_batt_curr_rm");
        resInfo.put("BMS_RMC_ModuleTempMax","bms_rmc_module_temp_max");
        resInfo.put("BMS_RMC_ModuleTempMin","bms_rmc_module_temp_min");
        resInfo.put(stdFieldTemp,"temp");
        resInfo.put("BMS_DCChrgConnect","bms_dc_chrg_connect");
        resInfo.put("OBC_ConnectSts_EV","obc_connect_sts_ev");
        resInfo.put("dc_obc_sts","dc_obc_sts");
        resInfo.put("BMS_SOC","bms_soc");
        resInfo.put("BMS_SOH","soh_cor");
        resInfo.put("BMS_HeatReq","bms_heatreq");
        resInfo.put("BMS_CoolReq","bms_coolreq");
        resInfo.put("heat_sts","heat_sts");
        resInfo.put("move_avg_point","move_avg_point");
        resInfo.put("temp_acc_err","temp_acc_err");
        resInfo.put("batter_map_value","batter_map_value");
        resInfo.put("batter_value_err","batter_value_err");
        resInfo.put("temp_interval_point","temp_interval_point");
        resInfo.put("batter_interval_point","batter_interval_point");
        resInfo.put("charge_init_point","charge_init_point_flag");
        resInfo.put(stdFieldPredictTime,"predict_time");
        resInfo.put("predict_time_v1","predict_time_v1");
        resInfo.put(stdFieldEstimateTime,"esti_time");
        resInfo.put(stdFieldEstimateTemp,"esti_temp");
        resInfo.put(stdFieldSocIntervalPoint,"soc_interval_point");
        resInfo.put("charge_id","charge_begin");
        resInfo.put("batt_soc_range","batterMap_soc_range");
        resInfo.put("batt_tem_range","batterMap_temp_range");
        resInfo.put("tempAcc_temp_range","tempAcc_temp_range");
        resInfo.put("tempAcc_batter_range","tempAcc_batter_range");
        resInfo.put("charge_frb","frb");
        resInfo.put("temp_acc","tempAccVal");
        resInfo.put("move_avg_process","move_avg_process");
        resInfo.put("esti_point_flag","esti_point_flag");
        resInfo.put("BMS_ChrgTime","bms_charge_time");
        resInfo.put("predict_time_multidimension","predict_time_multidimension");
        resInfo.put("aoiid","aoiid");
        resInfo.put("poiid","poiid");
        resInfo.put(srcFieldStartChargeTime,"startChargeTime");
        resInfo.put("flag","flag");
        resInfo.put("model_code","model_code");
        resInfo.put("handle_time","handle_time");
    }
    //字段区域 ---- dws多维模型 标准化字段列表 - end

    public JSONObject multiResInfo =new JSONObject();
    private void loadMultiRes(){
        //沿用充电主题字段
        multiResInfo.put(stdFieldDeviceId,"vin");
        multiResInfo.put(stdFieldItemTime,"tid");
        multiResInfo.put(stdFieldBrand,"brand");
        multiResInfo.put(stdFieldVehicleType,"vehicletype");
        multiResInfo.put(stdFieldBatterType,"batter_type");
        multiResInfo.put(stdFieldBatterCapacity,"batter_capacity");
        multiResInfo.put("BMS_ChrgSts","bms_chrg_sts");
        multiResInfo.put("BMS_BattCurr_RM","bms_batt_curr_rm");
        multiResInfo.put("BMS_RMC_ModuleTempMax","bms_rmc_module_temp_max");
        multiResInfo.put("BMS_RMC_ModuleTempMin","bms_rmc_module_temp_min");
        multiResInfo.put("BMS_DCChrgConnect","bms_dc_chrg_connect");
        multiResInfo.put("OBC_ConnectSts_EV","obc_connect_sts_ev");
        multiResInfo.put("BMS_SOC","bms_soc");
        multiResInfo.put("BMS_SOH","soh_cor");
        multiResInfo.put("BMS_HeatReq","bms_heatreq");
        multiResInfo.put("BMS_CoolReq","bms_coolreq");
        multiResInfo.put("aoiid","aoiid");
        multiResInfo.put("poiid","poiid");
        multiResInfo.put(srcFieldStartChargeTime,"startChargeTime");
        multiResInfo.put("model_code","model_code");
        multiResInfo.put("BMS_ChrgTime","bms_charge_time");
        //加工字段
        multiResInfo.put("handle_time","handle_time");
        multiResInfo.put("start_point_flag","start_point_flag");
        multiResInfo.put(stdFieldSocIntervalPoint,"soc_interval_point");
        //1-初始计算 2-初始默认值 3-更新计算
        multiResInfo.put("policyType","policyType");
        //"predict_time":"2023-04-14 10:28:08"
//        multiResInfo.put(stdFieldPredictTime,"predict_time")
        //"predict_time_multidimension":"112#76.6#99"
        multiResInfo.put("predict_time_multidimension","predict_time_multidimension");
        //esti_time 分钟
        multiResInfo.put("esti_time","predict_time");
    }
    //配置信息 ---- 连接配置 后续有公共的类，需要基于公共类进行对应的配置 - start

    public Map<String,String> confInfo = new HashMap<String,String>();
    private void loadConf(){
        if (ChargePredictDwsTask.aliOrInner == DwsStrConstant.ins().num1
            || ChargePredictDwsTask.aliOrInner == DwsStrConstant.ins().num3
        ){
            loadInnerNet();
        }else {
            loadAli();
        }
    }
    private void loadAli(){
        confInfo.put("phoenix.url","jdbc:phoenix:10.31.8.112,10.31.8.113,10.31.8.114:2181");
        confInfo.put("bootstrap.servers","10.31.8.112:9092,10.31.8.113:9092,10.31.8.114:9092");
//        confInfo.put("hdfs.path","hdfs://10.31.8.113:8020/external/data/dws/dws_bms_chargepredict_partition_data_v14/")
//        confInfo.put("flink.checkpoint.dir","hdfs://10.31.8.113:8020/external/data/dws/dws_bms_chargepredict_partition_data_cp")
        confInfo.put("hdfs.path","hdfs://nameservice1/external/data/dws/dws_multidimensional_charge_v3/");
        confInfo.put("flink.checkpoint.dir","hdfs://nameservice1/external/data/dws/dws_multidimensional_charge_cp");
        confInfo.put("zookeeper.quorum","10.31.8.112,10.31.8.113,10.31.8.114");


        confInfo.put("mysql.dynamic_conf.url","jdbc:mysql://10.255.128.243:3306/vp_business_zc04?useUnicode=true&characterEncoding=utf8&useSSL=false");
        confInfo.put("mysql.dynamic_conf.user","root");
        confInfo.put("mysql.dynamic_conf.password","vaas_sql*");
        confInfo.put("mysql.dynamic_conf.sql","select topic,config_key,config_value from config_data where topic='chargePredict'");
        confInfo.put("use_default_modelcode","false");
        confInfo.put("test","false");
    }
    private void loadInnerNet(){
        confInfo.put("bootstrap.servers","bd-zcpt-bd-zcpt-test-000001:9092,bd-zcpt-bd-zcpt-test-000002:9092,bd-zcpt-bd-zcpt-test-000003:9092,bd-zcpt-bd-zcpt-test-000004:9092,bd-zcpt-bd-zcpt-test-000005:9092");
        confInfo.put("hdfs.path","hdfs://nameservice1/external/data/dws/dws_multidimensional_charge_data/");
        confInfo.put("flink.checkpoint.dir","hdfs://nameservice1/external/data/dws/dws_multidimensional_charge_cp");
        confInfo.put("phoenix.url","jdbc:phoenix:bd-zcpt-bd-zcpt-test-000001,bd-zcpt-bd-zcpt-test-000002,bd-zcpt-bd-zcpt-test-000003:2181");
        confInfo.put("zookeeper.quorum","bd-zcpt-bd-zcpt-test-000001,bd-zcpt-bd-zcpt-test-000002,bd-zcpt-bd-zcpt-test-000003");


        confInfo.put("mysql.dynamic_conf.url","jdbc:mysql://10.255.128.243:3306/vp_business_zc04?useUnicode=true&characterEncoding=utf8&useSSL=false");
        confInfo.put("mysql.dynamic_conf.user","root");
        confInfo.put("mysql.dynamic_conf.password","vaas_sql*");
        confInfo.put("mysql.dynamic_conf.sql","select topic,config_key,config_value from config_data where topic='chargePredict'");
        confInfo.put("use_default_modelcode","false");
        confInfo.put("test","false");
    }

    /**
     * @description:
     *
     *
     * 配置信息 ---- 连接配置 后续有公共的类，需要基于公共类进行对应的配置 - end
     *  字段信息 ---- 公共字段 - start
     **/

    public String dwsFieldChargeBegin ="charge_begin";
    public String dwsFieldFrbField ="frb";
    public String timestampField ="timestamp";
    public String err ="error";
    public String timeFormat="yyMMddHHmmssSSS";
    public String zeroStr="0";
    public String oneStr="1";
    public String twoStr="2";
    public String intervalPoint="up_id";
    public String intervalPointFieldBatter ="batterIntervalId";
    public String blankStr="";
    public String blankStr9="-999999";
    public String tempAccField="tempAcc";
    public String charTab="\001";
    public String percentChar="%";
    public String comma=",";
    public String leftParentheses ="(";
    public String rightParentheses =")";
    public String colon=":";
    public String redisNameSpaceTemp ="dcp:t3:";
    public String redisNameSpaceBatter ="dcp:b3:";
    public String redisNameSpaceBatterSoc ="dcp:s:";
    public String redisDefaultField="avg";
    public String tempLeftBound="temp.bound.left";
    public String tempMoveAvgField="tempMoveAvg";
    public String batterMoveAvgField="batterMoveAvg";
    public String startxtempacc = "startX_tempAcc";
    public String endxtempacc = "endX_tempAcc";
    public String stepxtempacc = "stepX_tempAcc";
    public String startyTempacc = "startY_tempAcc";
    public String endyTempacc = "endY_tempAcc";
    public String stepyTempacc = "stepY_tempAcc";
    public String startxBattermap = "startX_batterMap";
    public String endxBattermap = "endX_batterMap";
    public String stepxBattermap = "stepX_batterMap";
    public String startyBattermap = "startY_batterMap";
    public String endyBattermap = "endY_batterMap";
    public String stepyBattermap = "stepY_batterMap";
    public String dwsFieldBatterMapValue ="batter_map_value";
    public String dwsFieldBatterValueErr ="batter_value_err";
    public String dwsFieldBatter ="bms_batt_curr_rm";
    public String frField ="charge_init_point";
    public String stdFieldEstiFirstPoint ="esti_first_point";
    public String stdFieldEstiPoint ="esti_point_flag";
    public String dwsFieldEstiTempList ="esti_temp_list";
    public String yyyyMmddss ="yyyy-MM-dd HH:mm:ss.SSS";
    public String yyyyMmddss1 ="yyyy-MM-dd HH:mm:ss";
    public String dtYyyyMmdd ="yyyy-MM-dd";
    public String dwsFieldInnerMaxSoc ="inner_max_soc";
    public String jsonBlank ="{}";
    public String utf8="utf-8";
    //字段信息 ---- 公共字段 - end
    //字段信息 ---- map表所用字段 - start

    /**
     * @description:温升map横坐标-温度
     **/
    public String paramTempAccTempStart ="temRiseTemMin";
    public String paramTempAccTempEnd ="temRiseTemMax";
    public String paramTempAccTempStep ="temRiseTemStep";
    /**
     * @description:温升map纵坐标-电流
     **/
    public String paramTempAccBatterStart ="temRiseElecMin";
    public String paramTempAccBatterEnd ="temRiseElecMax";
    public String paramTempAccBatterStep ="temRiseElecStep";
    /**
     * @description:电流map横坐标-温度
     **/
    public String paramBatterMapTempStart ="elecTemMin";
    public String paramBatterMapTempEnd ="elecTemMax";
    public String paramBatterMapTempStep ="elecTemStep";
    /**
     * @description:电流map横坐标-soc
     **/
    public String paramBatterMapSocStart ="elecSocMin";
    public String paramBatterMapSocEnd ="elecSocMax";
    public String paramBatterMapSocStep ="elecSocStep";
    /**
     * @description:电池容量
     **/
    public String paramBatterCapacity ="batteryRatedCapacity";
    /**
     * @description:温升map表更新点条件--温度
     **/
    public String paramTempAccIntervalTemp ="temRiseTemChange";
    /**
     * @description:温升map表更新点条件--电流
     **/
    public String paramTempAccIntervalBatter ="temRiseElecChange";
    /**
     * @description:电流map表更新点条件--电流
     **/
    public String paramBatterMapIntervalBatter ="elecElecDisparity";
    /**
     * @description:充电预测更新点条件--SOC
     **/
    public String paramSocEstimateIntervalSoc ="intervalPointIncrement";

    //字段信息 ---- map表所用字段 - end


}
